package com.vincent.kdp.ui.other.scan;

import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.vincent.kdp.ui.other.MainActivity;

/**
 * Created by Administrator on 2017/9/12 0012.
 */

public class ScanCodeManager implements IScanCodeConfig{

    private Activity acitivity;

    private int scanType;

    private IScanCodeChoiceTypeCall iScanCodeChoiceTypeCall;

    public ScanCodeManager(Activity acitivity){
        this.acitivity = acitivity;
    }

    /***
     *
     */
    public void showChoiceScanCodeMenthod(){
        new AlertDialog.Builder(acitivity).setTitle("温馨提示").setMessage("是谁在扫的？")
                .setPositiveButton("员工",new ScanCodeManager.Alert1())
                .setNegativeButton("客户",new ScanCodeManager.Alert2()).show();
    }

    public int getScanType() {
        return scanType;
    }

    public void setiScanCodeChoiceTypeCall(IScanCodeChoiceTypeCall iScanCodeChoiceTypeCall) {
        this.iScanCodeChoiceTypeCall = iScanCodeChoiceTypeCall;
    }

    /**
     * 点击员工
     */
    private class Alert1 implements DialogInterface.OnClickListener {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ScanCodeManager.this.scanType = STAFF_TYPE;
            if(null != iScanCodeChoiceTypeCall){
                iScanCodeChoiceTypeCall.onChoiceType(ScanCodeManager.this.scanType);
            }
        }
    }

    /**
     * 点击客户
     */
    private class Alert2 implements DialogInterface.OnClickListener {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ScanCodeManager.this.scanType = CLIENT_TYPE;
            if(null != iScanCodeChoiceTypeCall){
                iScanCodeChoiceTypeCall.onChoiceType(ScanCodeManager.this.scanType);
            }
        }
    }
}
